home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW Related / DTS MPW Goodies / GetMFSize < prev    next >
Encoding:
Text File  |  1990-09-14  |  3.6 KB  |  128 lines  |  [TEXT/MPS ]

  1. ##*****************************************************************************
  2. ##
  3. ##  Project Name:    UserScripts
  4. ##     File Name:    GetMFSize
  5. ##
  6. ##   Description:    This script will get the Multifinder SIZE resources,
  7. ##                    interpret them, and return the current size, minimum
  8. ##                    size, and default size.
  9. ##
  10. ##*****************************************************************************
  11. ##                       A U T H O R   I D E N T I T Y
  12. ##*****************************************************************************
  13. ##
  14. ##    Initials    Name
  15. ##    --------    -----------------------------------------------
  16. ##    GLA            Glenn L. Austin
  17. ##
  18. ##*****************************************************************************
  19. ##                      R E V I S I O N   H I S T O R Y
  20. ##*****************************************************************************
  21. ##
  22. ##      Date        Time    Author    Description
  23. ##    --------    -----    ------    ---------------------------------------------
  24. ##    08/19/89    10:37    GLA        Need to specify both upper and lowercase
  25. ##                                option names!
  26. ##    08/19/89    09:53    GLA        Original version
  27. ##
  28. ##*****************************************************************************
  29.  
  30. set exit 0
  31. set echo 0
  32.  
  33. set getCurrent false
  34. set getMinimum false
  35. set getDefault false
  36.  
  37. if ({#} == 1) && ("{1}" =~ /[¬-]?*/)
  38.     set getCurrent true
  39.     set getMinimum true
  40.     set getDefault true
  41. else
  42.     loop
  43.         if "{1}" =~ /-?+/            # Is this an option?
  44.         else
  45.             break
  46.         end
  47.         if "{1}" =~ /-[CMDcmd]/        # is this one of my options?
  48.             if "{1}" =~ /-[Cc]/            # Get current size
  49.                 set getCurrent true
  50.             end
  51.             if "{1}" =~ /-[Mm]/            # Get minimum size
  52.                 set getMinimum true
  53.             end
  54.             if "{1}" =~ /-[Dd]/            # Get default size
  55.                 set getDefault true
  56.             end
  57.         else
  58.             echo "### Error:  Undefined option ∂"{1}∂"" >Dev:Console
  59.             exit 1
  60.         end
  61.         shift 1
  62.     end
  63. end
  64.  
  65. if "{1} " == " "
  66.     echo "### Error:  No file specified!" >Dev:Console
  67.     exit 1
  68. end
  69.  
  70. set file "{1}"
  71.  
  72. files -t 'APPL' "{file}" ∑Dev:Null
  73. if {status} != 0
  74.     echo "### Error:  {file} is not an application!" >Dev:Console
  75.     exit 2
  76. end
  77.  
  78. derez -only 'SIZE' "{file}" "{RIncludes}"Types.r >"{MPW}"Tempfile ≥Dev:Null
  79.  
  80. set minSize 384
  81. set defSize 384
  82. set curSize 384
  83.  
  84. open "{MPW}"Tempfile
  85. find ∞ "{MPW}"Tempfile
  86. if `position -l` == 1
  87.     echo "### Warning:  {file} does not have a Multifinder size!" >Dev:Console
  88. else
  89.     find • "{MPW}"Tempfile
  90.     find /resource ∂'SIZE∂' ∂(-1/ "{MPW}"Tempfile
  91.     if {status} == 0            # found the MF default SIZE resource
  92.         find /[0-9]+,/ "{MPW}"Tempfile    # find default size
  93.         find Δ§ "{MPW}"Tempfile            # get before the selection
  94.         find /[0-9]+/ "{MPW}"Tempfile
  95.         set defSize `catenate "{MPW}"Tempfile.§`    # get the size in bytes
  96.         ( evaluate defSize = {defSize} ÷ 1024 ) ∑ Dev:Null    # convert to K
  97.         set curSize {defSize}            # default is curSize = defSize
  98.         find /[0-9]+/ "{MPW}"Tempfile
  99.         set minSize `catenate "{MPW}"Tempfile.§`    # get the size in bytes
  100.         ( evaluate minSize = {minSize} ÷ 1024 ) ∑ Dev:Null    # convert to K
  101.     end
  102.     find • "{MPW}"Tempfile
  103.     find /resource ∂'SIZE∂' ∂(0/ "{MPW}"Tempfile
  104.     if {status} == 0            # found the MF current SIZE resource
  105.         find /[0-9]+,/ "{MPW}"Tempfile    # find default size
  106.         find Δ§ "{MPW}"Tempfile            # get before the selection
  107.         find /[0-9]+/ "{MPW}"Tempfile
  108.         set curSize `catenate "{MPW}"Tempfile.§`    # get the size in bytes
  109.         ( evaluate curSize = {curSize} ÷ 1024 ) ∑ Dev:Null    # convert to K
  110.     end
  111. end
  112. close -y "{MPW}"Tempfile
  113. delete -y "{MPW}"Tempfile
  114.  
  115. set retVal ""
  116. if {getCurrent} == true
  117.     set retVal "{retVal} current={curSize}K"
  118. end
  119. if {getMinimum} == true
  120.     set retVal "{retVal} minimum={minSize}K"
  121. end
  122. if {getDefault} == true
  123.     set retVal "{retVal} default={defSize}K"
  124. end
  125.  
  126. echo "{retVal}"
  127.  
  128. exit